#pragma once

#include "rewine/impl/CExport.hpp"

#include <string>
#include <memory>

namespace rewine
{

enum class ImageFlavour : int {
    CUSTOM = 0,
    PE = 1,
    DSO = 2,
    DLLSO = 3,
};

class IImage {
public:

    virtual ~IImage() {};

public:

    virtual std::string fullname() const = 0;
    virtual std::string exportName() const = 0;
    virtual std::string moduleName() const = 0;  // without extName

    virtual ImageFlavour flavour() const = 0;

    // initialized means image is filled with fullname (mmap() file first) or memory section (read directly)
    virtual bool isInitialized() const = 0;

    // parsed means exportName is known
    virtual bool isParsed() const = 0;

    // loaded means everything is ready
    virtual bool isLoaded() const = 0;

    // failed means something is wrong
    virtual bool isFailed() const = 0;

    virtual int getLastError() const = 0;

    virtual void setSelf(const std::shared_ptr<IImage>& spImage) = 0;
    virtual std::shared_ptr<IImage> getSelf() = 0;

    virtual void setPinned(bool bValue) = 0;
    virtual bool isPinned() const = 0;
    virtual bool checkActivity() = 0;

    virtual void setImport(const std::shared_ptr<IImage>& spImported) = 0;
    virtual void onImported(const std::shared_ptr<IImage>& spImporter) = 0;

    virtual int getExportCount() const = 0;
    virtual IExport * getExportByIndex(unsigned int index) const = 0;
    virtual IExport * getExportByName(const std::string& name, uint16_t hint = -1) const = 0;

    virtual BOOL onEvent(DWORD dwReason) const = 0;
};

} // namespace rewine
